import React from 'react';

class Season extends React.Component {
    constructor(props) {
        super(props);
        this.displayName = 'Season';
        this.state = {
            datas: props.data
        }
    }

    componentWillReceiveProps(nextProps) {
        this.setState({
            datas: nextProps.data
        });
    }

    render() {
        console.log( " season render--------- " );
        // 赛季数据
        let dataList = this.state.datas.map( function( data, index ) {
            var { year, club, num, attack, defense, average } = data;
            return (
                <tr key={index}>
                    <td>{year}</td>
                    <td>{club}</td>
                    <td>{num}</td>
                    <td>{attack}</td>
                    <td>{defense}</td>
                    <td>{average}</td>
                </tr>
            )
        }.bind(this) )

        return (
            <tbody>
                {dataList}
            </tbody>
        );
    }
}

export default Season;
